Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

154
Visualizações
I want to get Origin from my input with the id "input_search". How can i do it it?

So i tried to solve this problem by doing

document.getElementbyId('seach_input') but it doesnt work

here my code:

var autocomplete = new google.maps.places.Autocomplete(document.getElementById("search_input"), 
{
    componentRestrictions: {'country' : ['AT']},
    fields: ['geometry', 'name'],
    types: ['establishment', 'geocode']
})

var directionsService = new google.maps.DirectionsService();

var request = {
  origin      : 'Imst, Österreich', // a city, full address, landmark etc
  destination : 'Innsbruck, Österreich',
  travelMode  : google.maps.DirectionsTravelMode.DRIVING
};

function getRoute(){
    directionsService.route(request, function(response, status) {
  if ( status == google.maps.DirectionsStatus.OK ) {

document.getElementById('preis').value = Math.round(response.routes[0].legs[0].distance.value / 1000 * 2) // the distance in metres
  }
  else {
    // oops, there's no route between these two locations
    // every time this happens, a kitten dies
    // so please, ensure your address is formatted properly
  }
});

}
<input type="text" required="" class="inputText" id="search_input" name="o" placeholder="Abholort"> <br> 

<input type="text" name="preis" readonly="" class="inputText" id="preis" placeholder="preis"><br>

        <button id="preisA" onclick="getRoute()" class="toggle-btn">Preis ausrechnen!</button>

i want in var request the origin text to be de value of the input text with the id "search_input" how can i do it?

about 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda